package com.example.myapplication;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;


import java.text.BreakIterator;
import java.text.StringCharacterIterator;

public class MainActivity extends AppCompatActivity {
    private Button btn_click;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btn_click=findViewById(R.id.bt_login);
        btn_click.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EditText username =findViewById(R.id.edit_username);
                EditText password =findViewById(R.id.edit_password);
                String str1 = username.getText().toString().trim();
                String str2 = password.getText().toString().trim();
                if(str1.equals("") || str2.equals("")){
                    Toast.makeText(MainActivity.this,"请输入用户名和密码！",Toast.LENGTH_LONG).show();
                } else if (str1.equals("yuanshen")&&str2.equals("qidong")) {
                    Toast.makeText(MainActivity.this,"登录成功啦！",Toast.LENGTH_LONG).show();
                    Intent intent = new Intent(MainActivity.this, SecondActivity2.class);
                    startActivity(intent);
                } else
                    Toast.makeText(MainActivity.this,"登录失败，请检查用户名或密码！",Toast.LENGTH_LONG).show();
            }
        });
        //Button button = (Button) findViewById(R.id.bt_login);
        //button.setOnClickListener(new View.OnClickListener() {
        //@Override
        //public void onClick(View view) {
        //EditText username = findViewById(R.id.edit_username);
        //EditText password = findViewById(R.id.edit_password);
        //String str1 = username.getText().toString().trim();
        //String str2 = password.getText().toString().trim();
        //if(!!str1.equals("") ||(str2.equals("")))
        //{
        //     show("请输入用户名和密码");
        //}

        //};

        // });
        // }
        //public void MyClick(View)
        //{
       //     EditText = (EditText) findViewById(R.id.edit_username);
        //    String str1 = editText.getText().toString();
         //   TextView textView = (TextView) findViewById(R.id.text_show);
         //   textView.setText(str1 = "欢迎使用");
       // }
    }
}